function SuperType(str){
  this.str = str??'none'
  this.arr = [1,2,3]
  this.fn = ()=>console.log(1)
}
const superType = new SuperType('superType')
console.log(superType)

function SubType (num){
  this.num = num
}

/**
 * 优点：可以复用父类方法
 * 缺点：父类的引用属性会被子类共享
 *      构建子对象时不能传参
 */
SubType.prototype = new SuperType('123')
SubType.prototype.constuctor = SubType

const subType = new SubType(123)
console.log(subType.str)

const subType2 = new SubType(456)
// 赋值会赋值给当前对象而不是原型
subType.str = '000'
console.log(subType2.str)
// 原地更改原型对象会影响其他对象
subType.arr.push('4')
console.log(subType2.arr)
// 引用类型直接赋值一样会赋值给当前对象
subType.arr = [0]
console.log(subType2.arr)